package com.focus.xyz.other.cases;

import com.focus.xyz.core.common.keyword.Action;
import com.focus.xyz.core.common.webdriver.DriverFactory;
import com.focus.xyz.core.utils.ProcessUtil;
import com.focus.xyz.other.pages.njhrss.DataPage;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;

/**
 * Created by chenmeng on 2016/4/28.
 */
public class ExportDataTest {
    private WebDriver driver;

    @Parameters({"browser"})
    @BeforeMethod(alwaysRun = true)
    public void setUp(String browser) throws Exception{
        driver = DriverFactory.getLocalDriver().getBrowser(browser);
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    }

    @AfterMethod(alwaysRun = true)
    public void tearDown(){
        if(driver!=null){
            driver.close();
            driver.quit();
        }
        if(ProcessUtil.findProcess("iexplore.exe")){
            ProcessUtil.killProcess("iexplore.exe");
        }
    }

    @Test
    public void export() throws Exception{
        DataPage dataPage = new DataPage(driver,new Action(driver));
        dataPage.openPage();
        dataPage.query();
        dataPage.export();
    }
}
